package com.gg.haoqi.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by GG on 2015/11/9.
 */
public class VpFragAdapter extends FragmentPagerAdapter {

    private List<Fragment> fms;
    private String[] titles;

    public VpFragAdapter(FragmentManager fm, List<Fragment> fms, String[] titles) {
        super(fm);
        this.fms = fms;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return fms != null && fms.size() > 0 ? fms.get(position) : null;
    }

    @Override
    public int getCount() {
        return fms != null && fms.size() > 0 ? fms.size() : 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles != null ? titles[position] : super.getPageTitle(position);
    }
}
